package com.exartisan.thanhdoanhn;

import android.content.Intent;
import android.view.View;

import com.exartisan.network.NetworkUtility;
import com.exartisan.network.RestConnector;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class MainActivity extends BaseActivity {

	/*
	 * protected void onCreate(Bundle savedInstanceState) {
	 * super.onCreate(savedInstanceState);
	 * setContentView(R.layout.activity_main); tvTest = (TextView)
	 * findViewById(R.id.tvTest);
	 * doNetWorkTask(WeirdParametersBuilder.BuildParams
	 * (WeirdParametersBuilder.BuildCategoryData()));
	 * doNetWorkTask(WeirdParametersBuilder
	 * .BuildParams(WeirdParametersBuilder.BuildEventData()));
	 * doNetWorkTask(WeirdParametersBuilder
	 * .BuildParams(WeirdParametersBuilder.BuildPostData(1, 1)));
	 * doNetWorkTask(WeirdParametersBuilder
	 * .BuildParams(WeirdParametersBuilder.BuildDetailGalleryData(1, 1)));
	 * doNetWorkTask(WeirdParametersBuilder.BuildParams(WeirdParametersBuilder.
	 * BuildCategoryForumData()));
	 * doNetWorkTask(WeirdParametersBuilder.BuildParams
	 * (WeirdParametersBuilder.BuildSurveyData(1)));
	 * doNetWorkTask(WeirdParametersBuilder
	 * .BuildParams(WeirdParametersBuilder.BuildSurveyContentData(1))); }
	 */

	@Override
	protected void initUI() {
		setContentView(R.layout.activity_main);
	}

	@Override
	protected void initProcess() {

	}

	public void onClickEvent(View v) {
		Intent i = new Intent(this, ListAcivity.class);
		i.putExtra("type", 0);
		startActivity(i);
	}

	public void onClickGallery(View v) {
		Intent i = new Intent(this, GalleryActivity.class);
		startActivity(i);
	}

	public void onClickActivities(View v) {
		Intent i = new Intent(this, ListAcivity.class);
		i.putExtra("categoryId", Long.valueOf(4));
		i.putExtra("type", 1);
		startActivity(i);
	}

	public void onClickIdiea(View v) {
		Intent i = new Intent(this, ListAcivity.class);
		i.putExtra("categoryId", Long.valueOf(5));
		i.putExtra("type", 1);
		startActivity(i);
	}

	public void onClickForum(View v) {
		Intent i = new Intent(getBaseContext(), ListCategoryForumActivity.class);
		startActivity(i);
	}

	public void onClickContest(View v) {
		Intent i = new Intent(this, ListAcivity.class);
		i.putExtra("type", 2);
		startActivity(i);
	}

	private void doNetWorkTask(RequestParams requestParams) {
		if (NetworkUtility.checkNetworkState(getApplicationContext())) {
			RestConnector.post("", requestParams,
					new AsyncHttpResponseHandler() {
						@Override
						public void onSuccess(int arg0, String response) {
							// tvTest.setText(response);
							// tvTest.setText(StupidResponseTranslater.getQuestion(response));
							super.onSuccess(arg0, response);
						}

						@Override
						public void onFailure(Throwable arg0, String arg1) {
							super.onFailure(arg0, arg1);
						}
					});
		}
	}

}
